﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

#if UNITY_EDITOR
using UnityEditor;
#endif

public class GT_NodePopupWindow : EditorWindow{

    #region Variables
    static GT_NodePopupWindow curPopup;
    string wantedName = "Enter a name...";
    #endregion

    #region Main Methods
    public static void InitNodePopup()
    {
        curPopup = (GT_NodePopupWindow)EditorWindow.GetWindow<GT_NodePopupWindow>();
        curPopup.titleContent.text = "Node Popup";
    }
    #endregion

    private void OnGUI()
    {
        GUILayout.Space(20);
        GUILayout.BeginHorizontal();
        GUILayout.Space(20);

        GUILayout.BeginVertical();

        EditorGUILayout.LabelField("Create New Graph: ", EditorStyles.boldLabel);
        wantedName = EditorGUILayout.TextField("Enter Name: ", wantedName);
        GUILayout.Space(10);

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Create Graph", GUILayout.Height(40)))
        {
            if (!string.IsNullOrEmpty(wantedName) && wantedName != "Enter a name...")
            {
                GT_NodeUtils.CreateNewGraph(wantedName);
                curPopup.Close();
            }
            else
            {
                EditorUtility.DisplayDialog("Node mesasge: ", "Please enter a valid graph name!", "OK");
            }
        }

        if (GUILayout.Button("Cancel", GUILayout.Height(40)))
        {
            curPopup.Close();
        }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();

        GUILayout.Space(20);
        GUILayout.EndHorizontal();
        GUILayout.Space(20);
    }

    #region Utility Methods

    #endregion

}
